package ifosup.gaelle.file;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
//import java.io.InputStream;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		File repertoire = new File("C:\\ MonRepertoire");
		repertoire.mkdirs();
		System.out.println(repertoire.exists()+ " " +repertoire.getPath());
		
		File texte = new File(repertoire,"test.txt");
		FileOutputStream font = null;
		try {
			font = new FileOutputStream(texte);
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		String s ="Hello.baby";
		try {
			font.write(s.getBytes());
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		try {
			font.close();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		StringBuffer sb = new StringBuffer();
		FileInputStream lecture = null;
		try {
			lecture = new FileInputStream("C:\\ MonRepertoire\\test.txt");
		} catch (FileNotFoundException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}
		int c = 0;
		try {
			while((c=lecture.read())>=0)
			{
				sb.append((char) c);
			}
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		System.out.println(sb);
	}

}
